// components/user-center/user-center.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    isLogin:{
      type:Boolean,
      value:false
    },
    loginInfo:{
      type:Object,
      value:{}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    optionList:[
      // {
      //   name:'设置',
      //   icon:'./images/setting-icon.png',
      //   isWeb:false,
      //   url:'/pages/setting/setting'
      // },
      {
        name:'健康知识',
        icon:'./images/healthy.png',
        isWeb:true,
        url:'https://www.machineeye.cn/hongfei-page/jiankang-page/'
      },
      // {
      //   name:'客服中心',
      //   icon:'./images/kefu-icon.png',
      //   isWeb:true,
      //   url:'/pages/setting/setting'
      // },
      {
        name:'关于我们',
        icon:'./images/about.png',
        isWeb:true,
        url:'https://www.machineeye.cn/hongfei-page/about-us/'
      },
     
      {
        name:'帮助中心',
        icon:'./images/help.png',
        isWeb:true,
        url:'https://www.machineeye.cn/hongfei-page/help-web/'
      },
       {
        name:'城市CEO申请',
        icon:'./images/ceo.png',
        isWeb:true,
        url:'https://www.machineeye.cn/hongfei-page/ceo-register/'
      },
      // {
      //   name:'绑定邀请人',
      //   icon:'./images/about-icon.png',
      //   isWeb:true,
      //   url:`https://www.machineeye.cn/bind/index.html?token=xxx/#`
      // }
    ],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleNavTo(e){
      
      let isWeb = e.currentTarget.dataset.isWeb
      let url = e.currentTarget.dataset.url
      if(isWeb){
        app.globalData.webViewUrl = url
        wx.navigateTo({
          url: '/pages/webPage/webPage',
        })
      } else {
        wx.navigateTo({
          url: url,
        })
      }
    },
    navToUserInfo(){
      if(!this.properties.isLogin){
        return wx.navigateTo({
          url:'/pages/login/login'
        })
      }
      wx.navigateTo({
        url: '/pages/userInfo/userInfo',
      })
    },
    changeDevice(){
      this.triggerEvent('changedevice')
    },
    openKefu(){
      wx.makePhoneCall({
        phoneNumber: '4007777776',
      })
    },
    openSetting(){
      wx.navigateTo({
        url: '/pages/setting/setting',
      })
    }
  },
  created(){
    
  },
  attached(){
    console.log('展示了')
    // let token = this.properties.loginInfo.token
    //   let url = `https://www.machineeye.cn/bind/index.html?token=${token}/#`
    //   this.setData({
    //     [`optionList[5].url`]:url
    //   })
  },
})
